package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsBrand;
import com.mall.mapper.SmsBrandMapper;
import com.mall.service.SmsBrandService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsBrandServiceImpl extends ServiceImpl<SmsBrandMapper, SmsBrand> implements SmsBrandService {

    @Resource
    private SmsBrandMapper brandMapper;

    @Override
    public SmsBrand getById(Integer id) {
        return brandMapper.selectById(id);
    }

    @Override
    public List<SmsBrand> getAll() {
        return brandMapper.selectList(null);
    }

    @Override
    public boolean deleteById(Integer id) {
        return brandMapper.deleteById(id) > 0;
    }

    @Override
    public boolean save(SmsBrand smsBrand) {
        if(smsBrand.getId() == null)
        {
            return brandMapper.insert(smsBrand) > 0;
        }else{
            return  brandMapper.updateById(smsBrand) > 0;
        }
    }
}
